import { formatNumber } from '@/utils/util'
import { QuestionCircleOutlined } from '@ant-design/icons'
import { Space, TableColumnsType, Tooltip, Typography } from 'antd'
import dayjs from 'dayjs'
import { NavigateFunction } from 'react-router-dom'
import { DashboardSaleGroupVO as ITableData } from './types'
export const useIndexColumns = ({
  navigate,
  TableColumns,
  isSentry,
}: {
  navigate: NavigateFunction
  TableColumns: Record<string, any>
  isSentry: boolean
}): TableColumnsType<ITableData> => [
  {
    title: TableColumns.title,
    dataIndex: 'groupKey',
    key: 'groupKey',
    align: 'center',
    fixed: 'left',
    width: 90,
    render: (info) => {
      return info || '-'
    },
  },
  {
    title: '销售额',
    dataIndex: 'saleAmount',
    key: 'saleAmount',
    align: 'center',
    sorter: true,
    defaultSortOrder: 'descend',
    width: 90,
    hidden: isSentry,
    render: (info) => {
      return formatNumber(info)
    },
  },
  {
    title: '销售数量',
    dataIndex: 'saleQty',
    key: 'saleQty',
    align: 'center',
    sorter: true,
    width: 90,
    render: (info) => {
      return formatNumber(info)
    },
  },
  {
    title: (
      <div>
        折扣率
        <span style={{ marginLeft: 4, cursor: 'pointer' }}>
          <Tooltip title="折扣率 = 销售额/吊牌额，表示实际销售价格相比于吊牌价的折扣">
            <QuestionCircleOutlined />
          </Tooltip>
        </span>
      </div>
    ),
    dataIndex: 'totalDiscount',
    key: 'totalDiscount',
    align: 'center',
    width: 80,
    hidden: isSentry,
    render: (info) => Number(info || 0) + '%',
  },
  {
    title: (
      <div>
        总库存 / 总周转 (含采购)
        <span style={{ marginLeft: 4, cursor: 'pointer' }}>
          <Tooltip
            title={
              <div>
                <div>总库存（含采购）：包含仓库、门店、在途的所有库存，T-1的数据</div>
                <div>总周转：总库存 / 日销，销售满14天的取最近14天的日销，不满14天的取实际销售天数的日销</div>
              </div>
            }
          >
            <QuestionCircleOutlined />
          </Tooltip>
        </span>
      </div>
    ),
    dataIndex: 'stockWithPurchase',
    key: 'stockWithPurchase',
    align: 'center',
    width: 166,
    render: (info, rows) => {
      return formatNumber(info) + ' / ' + (rows?.turnoverWithPurchase || '-')
    },
  },
  {
    title: (
      <div>
        总库存 / 总周转 (不含采购)
        <span style={{ marginLeft: 4, cursor: 'pointer' }}>
          <Tooltip
            title={
              <div>
                <div>总库存（不含采购）：不含采购在途的所有库存，T-1的数据</div>
                <div>总周转：总库存 / 日销，销售满14天的取最近14天的日销，不满14天的取实际销售天数的日销</div>
              </div>
            }
          >
            <QuestionCircleOutlined />
          </Tooltip>
        </span>
      </div>
    ),
    dataIndex: 'stockWithoutPurchase',
    key: 'stockWithoutPurchase',
    align: 'center',
    width: 170,
    render: (info, rows) => {
      return formatNumber(info) + ' / ' + (rows?.turnoverWithoutPurchase || '-')
    },
  },
  {
    title: (
      <div>
        畅销款数量 / 占比
        <span style={{ marginLeft: 4, cursor: 'pointer' }}>
          <Tooltip
            title={
              <div>
                <div>畅平滞标签：数据来源于EOP，由系统输出，经管部修正，系商品销售情况判断周期内最新的畅滞销情况</div>
                <div>畅销款占比：该分组下的畅销款数量 / 筛选条件下的畅销款总数</div>
              </div>
            }
          >
            <QuestionCircleOutlined />
          </Tooltip>
        </span>
      </div>
    ),
    dataIndex: 'hotSaleQty',
    key: 'hotSaleQty',
    align: 'center',
    width: 120,
    render: (info, rows) => {
      return formatNumber(info) + ' / ' + (Number(rows?.hotSaleRate || 0) + '%')
    },
  },
  {
    title: (
      <div>
        滞销款数量 / 占比
        <span style={{ marginLeft: 4, cursor: 'pointer' }}>
          <Tooltip
            title={
              <div>
                <div>畅平滞标签：数据来源于EOP，由系统输出，经管部修正，系商品销售情况判断周期内最新的畅滞销情况</div>
                <div>滞销款占比：该分组下的滞销款数量 / 筛选条件下的滞销款总数</div>
              </div>
            }
          >
            <QuestionCircleOutlined />
          </Tooltip>
        </span>
      </div>
    ),
    dataIndex: 'slowSaleQty',
    key: 'slowSaleQty',
    align: 'center',
    width: 120,
    render: (info, rows) => {
      return formatNumber(info) + ' / ' + (Number(rows?.slowSaleRate || 0) + '%')
    },
  },
]
